<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="lib/js/jquery3.6.0.js"></script>
    <script src="lib/js/bootstrap.js"></script>
    <link rel="stylesheet" href="lib/css/bootstrap.css">
</head>
<body>
<div class="container">
    <div class="col-md-2"></div>
    <div class="col-md-8">

        <div class="form-group">
            <label for="exampleInputEmail1">用户名</label>
            <input name="username" type="email" class="form-control" id="exampleInputEmail1" placeholder="Email">
        </div>

        <!-- <div class="form-group">
             <label for="exampleInputPassword1">Password</label>
             <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
         </div>
         <div class="form-group">
             <label for="exampleInputFile">File input</label>
             <input type="file" id="exampleInputFile">
             <p class="help-block">Example block-level help text here.</p>
         </div>
         <div class="checkbox">
             <label>
                 <input type="checkbox"> Check me out
             </label>
         </div>-->
        <button id="sub" type="submit" class="btn btn-default">Submit</button>
        <!--        <a href="http:\\www.baidu.com">sss</a>-->
    </div>
    <div class="col-md-2"></div>

</div>
<form action="">
    <input type="submit" name="" value="提交">
</form>
<script type="text/javascript">
    $(function () {
        var $username = $("#username");
        var isEmail = function (email) {
            return /^\w{2,14}$/.test(email);
        };

        /*
            $("a").click(function (event) {
                    event.preventDefault();
            })*/
        $("#sub").click(function (event) {
            event.preventDefault();
            var username = $username.val().trim();
            if (isEmail(username)) {
                $.ajax({
                    url: "./login.do",
                    type: "GET",
                    contentType: "text",
                    data: {
                        username:username
                    }
                })
            }else {
                alert("格式错误")
            }
        })
    })
</script>
</body>

</html>